<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>伪类选择符 | Introduction</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="./属性选择符.html" />
    
    
    <link rel="prev" href="./伪对象选择符.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="1.7"
        data-chapter-title="伪类选择符"
        data-filepath="伪类选择符.md"
        data-basepath="."
        data-revision="Fri Sep 01 2017 15:57:44 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="CSS选择符.html">
            
                
                    <a href="./CSS选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        CSS选择符
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="CSS的www.html">
            
                
                    <a href="./CSS的www.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        CSS的www
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="CSS的引入.html">
            
                
                    <a href="./CSS的引入.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        CSS的引入
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="ID及class选择符.html">
            
                
                    <a href="./ID及class选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        ID及class选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="关系选择符.html">
            
                
                    <a href="./关系选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        关系选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="群组选择符.html">
            
                
                    <a href="./群组选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        群组选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="伪对象选择符.html">
            
                
                    <a href="./伪对象选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        伪对象选择符
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="1.7" data-path="伪类选择符.html">
            
                
                    <a href="./伪类选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.7.</b>
                        
                        伪类选择符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="属性选择符.html">
            
                
                    <a href="./属性选择符.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.8.</b>
                        
                        属性选择符
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="CSS样式.html">
            
                
                    <a href="./CSS样式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        CSS样式
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="CSS字体，颜色和文本属性.html">
            
                
                    <a href="./CSS字体，颜色和文本属性.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        CSS字体，颜色和文本属性
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="Bootstrap.html">
            
                
                    <a href="./Bootstrap.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Bootstrap
                    </a>
            
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >Introduction</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h2 id="&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x7B26;">&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x7B26;</h2>
<blockquote>
<p>&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x7B26;&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#x53EB;&#x505A;&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x7B26;&#xFF0C;&#x5B83;&#x5141;&#x8BB8;&#x7ED9;html&#x4E0D;&#x5B58;&#x5728;&#x7684;&#x6807;&#x7B7E;&#xFF08;&#x6807;&#x7B7E;&#x7684;&#x67D0;&#x79CD;&#x72B6;&#x6001;&#xFF09;&#x8BBE;&#x7F6E;&#x6837;&#x5F0F;&#xFF0C;&#x6BD4;&#x5982;&#x8BF4;&#x6211;&#x4EEC;&#x7ED9;html&#x4E2D;&#x4E00;&#x4E2A;&#x6807;&#x7B7E;&#x5143;&#x7D20;&#x7684;&#x9F20;&#x6807;&#x6ED1;&#x8FC7;&#x7684;&#x72B6;&#x6001;&#x6765;&#x8BBE;&#x7F6E;&#x5B57;&#x4F53;&#x989C;&#x8272;</p>
</blockquote>
<table>
<thead>
<tr>
<th>&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x7B26;</th>
<th>&#x4F5C;&#x7528;</th>
</tr>
</thead>
<tbody>
<tr>
<td>E:link</td>
<td>&#x8BBE;&#x7F6E;&#x8D85;&#x94FE;&#x63A5;a&#x5728;&#x672A;&#x88AB;&#x8BBF;&#x95EE;&#x524D;&#x7684;&#x6837;&#x5F0F;</td>
</tr>
<tr>
<td>E:visited</td>
<td>&#x8BBE;&#x7F6E;&#x8D85;&#x94FE;&#x63A5;a&#x5728;&#x5176;&#x94FE;&#x63A5;&#x5730;&#x5740;&#x5DF2;&#x88AB;&#x8BBF;&#x95EE;&#x8FC7;&#x65F6;&#x7684;&#x6837;&#x5F0F;&#x3002;</td>
</tr>
<tr>
<td>E:hover</td>
<td>&#x8BBE;&#x7F6E;&#x5143;&#x7D20;&#x5728;&#x5176;&#x9F20;&#x6807;&#x60AC;&#x505C;&#x65F6;&#x7684;&#x6837;&#x5F0F;&#x3002;</td>
</tr>
<tr>
<td>E:active</td>
<td>&#x8BBE;&#x7F6E;&#x5143;&#x7D20;&#x5728;&#x88AB;&#x7528;&#x6237;&#x6FC0;&#x6D3B;&#x65F6;&#x7684;&#x6837;&#x5F0F;&#x3002;</td>
</tr>
<tr>
<td>E:first-child</td>
<td>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:last-child</td>
<td>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:only-child</td>
<td>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x4EC5;&#x6709;&#x7684;&#x4E00;&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:nth-child(n)</td>
<td>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x7B2C;n&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:nth-last-child(n)</td>
<td>&#x5339;&#x914D;&#x7236;&#x5143;&#x7D20;&#x7684;&#x5012;&#x6570;&#x7B2C;n&#x4E2A;&#x5B50;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:first-of-type</td>
<td>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:last-of-type</td>
<td>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:only-of-type</td>
<td>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x552F;&#x4E00;&#x7684;&#x4E00;&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:nth-of-type(n)</td>
<td>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x7B2C;n&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
<tr>
<td>E:nth-last-of-type(n)</td>
<td>&#x5339;&#x914D;&#x540C;&#x7C7B;&#x578B;&#x4E2D;&#x7684;&#x5012;&#x6570;&#x7B2C;n&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;E&#x3002;</td>
</tr>
</tbody>
</table>
<pre><code>        &lt;style&gt;
            /*&#x4F2A;&#x7C7B;&#x9009;&#x62E9;&#x5668;&#xFF0C;&#x53EF;&#x4EE5;&#x7406;&#x89E3;&#x4E3A;&#x662F;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x7684;&#x72B6;&#x6001;*/
            a:link{/*&#x5728;&#x672A;&#x88AB;&#x8BBF;&#x95EE;&#x524D;&#x7684;&#x6837;*/
                color: black;
            }
            a:hover{/*&#x9F20;&#x6807;&#x60AC;&#x505C;*/
                color: red;
            }
            a:active{/*&#x5728;&#x88AB;&#x7528;&#x6237;&#x6FC0;&#x6D3B;*/
                color: yellowgreen;
            }
            a:visited{/*&#x5DF2;&#x88AB;&#x8BBF;&#x95EE;&#x8FC7;*/
                color: blue;
            }
            .input{
                color: red;
            }
            .input:focus{/*&#x6210;&#x4E3A;&#x8F93;&#x5165;&#x7126;&#x70B9;*/
                color: skyblue;
            }
            /*&#x5B50;&#x5143;&#x7D20;&#x7CFB;&#x5217;(&#x4E0D;&#x533A;&#x5206;&#x7C7B;&#x578B;)*/
            ul&gt;li:nth-child(1){/*ul&#x4E0B;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x5B57;&#x5143;&#x7D20;*/
                background: pink;
            }
            ul&gt;li:nth-child(odd){/*&#x5947;&#x6570;&#xFF0C;2n+1*/
                background: pink;
            }
            ul&gt;li:nth-child(even){/*&#x5076;&#x6570;&#xFF0C;2n*/
                background: skyblue;
            }
            ul&gt;li:first-child,ul&gt;li:last-child{
                background: black;
            }
            ul&gt;li:first-of-type{
                background: black;
            }
            /*&#x5B50;&#x7C7B;&#x578B;&#x7CFB;&#x5217;*/
            ul&gt;li:first-of-type(odd){/*&#x63A7;&#x5236;ul&#x4E0B;&#x7684;&#x9762;&#x7684;&#x7B2C;&#x4E00;&#x4E2A;li&#x7C7B;&#x578B;&#x7684;&#x5B50;&#x5143;&#x7D20;*/
                background: black;
            }
            ul&gt;div:nth-of-type(even){/*&#x5012;&#x6570;&#x7B2C;n&#x4E2A;&#x540C;&#x7EA7;&#x5144;&#x5F1F;&#x5143;&#x7D20;*/
                background: greenyellow;
            }

            ul&gt;:nth-child(3n){/*&#x63A7;&#x5236;&#x4E0B;&#x9762;&#x7684;&#x6240;&#x4EE5;&#x5B50;&#x5143;&#x7D20;&#xFF0C;&#x5E76;&#x4E14;&#x4F4D;&#x7F6E;&#x662F;3n&#x7684;&#x500D;&#x6570;*/
                background:red;
            }
            ul&gt;:not(li){/*&#x63A7;&#x5236;&#x975E;li&#x7684;&#x5B50;&#x5143;&#x7D20;*/
                font-size: 20px;
            }
        &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;a href=&quot;http://www.baidu&#x3002;com&quot;&gt;&#x6211;&#x7684;&lt;/a&gt;
        &lt;input    type=&quot;text&quot; class=&quot;input&quot; /&gt;
            &lt;ul&gt;
                &lt;p&gt;1&lt;/p&gt;
                &lt;div&gt;2&lt;/div&gt;
                &lt;div&gt;3&lt;/div&gt;
                &lt;div&gt;4&lt;/div&gt;
                &lt;div&gt;5&lt;/div&gt;
                &lt;li&gt;1111&lt;/li&gt;
                &lt;li&gt;2222&lt;/li&gt;
                &lt;li&gt;3333&lt;/li&gt;            
            &lt;/ul&gt;
    &lt;/body&gt;
</code></pre>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="./伪对象选择符.html" class="navigation navigation-prev " aria-label="Previous page: 伪对象选择符"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="./属性选择符.html" class="navigation navigation-next " aria-label="Next page: 属性选择符"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"livereload":{}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
